package com.hznc.wcs.flowable.behavior;

import com.hznc.wcs.flowable.candidate.BpmTaskCandidateInvoker;
import lombok.Setter;
import org.flowable.bpmn.model.Activity;
import org.flowable.bpmn.model.UserTask;
import org.flowable.engine.impl.bpmn.behavior.AbstractBpmnActivityBehavior;
import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
import org.flowable.engine.impl.bpmn.behavior.UserTaskActivityBehavior;
import org.flowable.engine.impl.bpmn.parser.factory.DefaultActivityBehaviorFactory;

/**
 * @Description :
 * @Date : 2024/6/21
 * @Author : ChenJin
 * @Version : v1.0.0
 **/
@Setter
public class BpmActivityBehaviorFactory extends DefaultActivityBehaviorFactory {

    private BpmTaskCandidateInvoker taskCandidateInvoker;

    @Override
    public UserTaskActivityBehavior createUserTaskActivityBehavior(UserTask userTask) {
        BpmUserTaskActivityBehavior bpmUserTaskActivityBehavior = new BpmUserTaskActivityBehavior(userTask);
        bpmUserTaskActivityBehavior.setTaskCandidateInvoker(taskCandidateInvoker);
        return bpmUserTaskActivityBehavior;
    }

    @Override
    public ParallelMultiInstanceBehavior createParallelMultiInstanceBehavior(Activity activity, AbstractBpmnActivityBehavior behavior) {
        BpmParallelMultiInstanceBehavior parallelMultiInstanceBehavior = new BpmParallelMultiInstanceBehavior(activity,behavior);
        parallelMultiInstanceBehavior.setTaskCandidateInvoker(taskCandidateInvoker);
        return parallelMultiInstanceBehavior;
    }

    @Override
    public SequentialMultiInstanceBehavior createSequentialMultiInstanceBehavior(Activity activity, AbstractBpmnActivityBehavior behavior) {
        BpmSequentialMultiInstanceBehavior sequentialMultiInstanceBehavior = new BpmSequentialMultiInstanceBehavior(activity, behavior);
        sequentialMultiInstanceBehavior.setTaskCandidateInvoker(taskCandidateInvoker);
        return sequentialMultiInstanceBehavior;
    }
    
    
}
